package www.lagou.dao;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import www.lagou.entity.Phone;
import www.lagou.utils.DruidUtils;

import java.sql.SQLException;
import java.util.List;

/**
 * 手机表数据库操作
 *
 * @author Shuxian Huang
 */
public class PhoneDao {

    public List<Phone> findPhoneBySql(String sql, Object... params) throws SQLException {

        //1、创建QueryRunner
        QueryRunner qr = new QueryRunner(DruidUtils.getDataSource());

        //2、执行查询
        return qr.query(sql, new BeanListHandler<Phone>(Phone.class), params);
    }
}
